from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

bjw = webdriver.Chrome()

# 隐式等待 1 秒
bjw.implicitly_wait(1)

bjw.get('https://www.51bijiawang.cn/test-pc/#/index')  # 测试服
# driver.get('http://www.shihuabjw.com/#/index')  # 正式服

# 点击按钮 【请登录，免费注册】
bjw.find_element(By.CLASS_NAME, 'mainColor').click()

# 点击按钮 【密码登录】
bjw.find_element(
    By.XPATH, '//*[@id="app"]/div[1]/div[2]/div/div[2]/div[1]/div[2]').click()

# 输入账号密码 --> 登录
username = bjw.find_element(
    By.CSS_SELECTOR, '[placeholder="手机号"]').send_keys('17707235785')
password = bjw.find_element(
    By.CSS_SELECTOR, '[placeholder="密码"]').send_keys('123456bjw')
bjw.find_element(
    By.CSS_SELECTOR, '.el-button--primary').click()


# 退出登录
bjw.find_element(By.CSS_SELECTOR, ".logout").click()

# sleep(1)
bjw.find_element(
    By.CSS_SELECTOR, '.el-message-box__btns>button:nth-child(2)').click()


# 关闭
# sleep(10)
bjw.quit()
